/***************************************************************************
 *   Copyright (C) 2006 by Sergejs Melderis   *
 *   smelderis@yahoo.com   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef LANGUAGECHOOSER_H
#define LANGUAGECHOOSER_H

#include <qwidget.h>
#include <qlabel.h>
#include <qbutton.h>
class QPoint;
class QMouseEvent;
class QToolButton;
class QPopupMenu;
class QPixmap;
class QPainter;
class QPaintEvent;

class FlatButton : public QButton
{
    Q_OBJECT
public:
    FlatButton(QWidget *parent, QPixmap *pix);
    ~FlatButton();
protected:
    void drawButton(QPainter *p);
    void drawButtonLabel(QPainter *p);
    void paintEvent(QPaintEvent *);
private:
    QPixmap *pixmap;
};

class LanguageLabel : public QLabel
{
    Q_OBJECT
public:
     LanguageLabel(QWidget *parent = 0, const char *name = 0);
     ~LanguageLabel();
     void changeName(const QString &name);
     void setPopupMenu(QPopupMenu *menu);
     QPopupMenu* getMenu()const;
signals:
    void mousePressed(QPoint &p); 
protected:
    void mousePressEvent(QMouseEvent *e);
private:
    QPopupMenu *mMenu;
};


class QPixmap;
/**
	@author Sergejs Melderis <smelderis@yahoo.com>
	
*/
class LanguageChooser : public QWidget
{
    Q_OBJECT
public:
    LanguageChooser( 
                    const QString &from, const QString &to,
                    QWidget *parent = 0, const char *name = 0);

    ~LanguageChooser();
    QPopupMenu* getFromMenu() const;
    QPopupMenu* getToMenu() const;
signals:
    void languageChange(const QString &from, const QString &to);
    void translateClipboard(const QString &word);
private:
    QPixmap *pmTranslateClipboard;
    QPixmap *pc;
    FlatButton *mTranslateClipboardB;
    FlatButton *mSwitchB;
    QLabel *mTranslateL;
    LanguageLabel *mFromL;
    LanguageLabel *mToL;
    QPopupMenu *mFromMenu;
    QPopupMenu *mToMenu;
    QPopupMenu *mToShortMenu;
public slots:
    void translateClipboard();
private slots:
    void fromMenuActivated(int id);
    void toMenuActivated(int id);
    void switchLabels();
};



#endif
